import axios from '@/libs/api.request'
export const queryUser = (currentPage, pageSize, isPaging, search) => { // 查询所有的角色
  const params = {
    currentPage,
    pageSize, // 每页几条
    isPaging, // 是否开启分页
    search // 模糊查询
  }
  return axios.request({
    url: 'api/user',
    method: 'get',
    params
  })
}
export const addUserS = (mobile, password, realName, role,avatar) => { // 添加用户
  const data = {
    mobile,
    password,
    realName,
    role,
    avatar
  }
  return axios.request({
    url: 'api/user',
    method: 'post',
    data
  })
}
export const deleteUser = (id) => { // 删除指定的用户
  return axios.request({
    url: 'api/user/' + id,
    method: 'delete'
  })
}
export const ChangeUser = (id, mobile, realName, role,avatar) => { // 修改指定用户
  const data = {
    mobile,
    realName,
    role,
    avatar
  }
  return axios.request({
    url: 'api/user/' + id,
    method: 'put',
    data
  })
}

export const ChangeUserPwd = (oldPassword, password) => { // 修改指定用户的密码
  const data = {
    oldPassword,
    password
  }
  return axios.request({
    url: 'api/user/access/resetPsw',
    method: 'put',
    data
  })
}
export const removeImage = (id)=>{   //删除上传的图片
  return axios.request({
    url:"api/upload/"+id,
    method:"delete",
  })
}
